<script>
$(document).ready(function(){
    $('#razred_ucenik_razred_list').addClass('ucenik_list');
    var uceniks = $('.image_upload');
    $.each(uceniks, function(i,n){
    new AjaxUpload('#' + n.id, {action: '/administracija.php/ucenik/uploadImage/id/' + n.id, autoSubmit: true, onComplete: function(file, response) { $('#' + n.id).html(response);}});
    });

    $("#tabs").tabs();
});
</script>

<style>
  .ui-tabs .ui-tabs-hide {
     display: none;
  }

</style>

<?php
  use_helper('jQuery', 'Form');
?>

<!--
<ul id="razred_in_menu">
  <li><?php echo link_to("<span>Dnevnik rada</span>", 'razred/dnevnik?razred_id='.$sf_request->getParameter('razred_id'), array('class' => 'button')) ?></li>
  <li><?php echo link_to("<span>Grupni unos ocena</span>", 'razred/grupniUnos?razred_id='.$sf_request->getParameter('razred_id'), array('class' => 'button')) ?></li>
</ul>
-->
<div id="feedback"></div>
<div id="tabs">
    <ul>
        <li><a href="#fragment-1"><span>Profesori</span></a></li>
        <li><a href="#fragment-2"><span>Slike</span></a></li>
        <li><a href="#fragment-3"><span>Rasporedi</span></a></li>
    </ul>

   <form action="" method="POST" id="fragment-1">
     <table style="display:inline; float: left; margin-right: 15px;" id='podesavanja_razreda'>
       <?php echo $form ?>
       <tr>
         <td colspan="2">
           <a id="dugme" onclick="document.forms[0].submit(); return false;" href="javascript: void(0)" class="button"><span>Sačuvaj</span></a>
         </td>
       </tr>
     </table>
   </form>

   <div id="fragment-2">
   <table cellpadding='0' cellspacing='0' style='padding: 5px; border: 1px solid #000;'>
         <?php
         $i = 0;
         foreach($uceniks as $ucenik)
         {
             if(($i++ % 8) == 0)
               echo "<tr>"?>
           <td style="text-align:center;font-size: 10px;">
             <div class="image_upload" id="uc_<?php echo $ucenik->getId() ?>">
               <?php echo Functions::image($ucenik->getId(), $ucenik->getPol()); ?>
             </div>
             <?php echo mb_substr($ucenik, 0, 12, 'utf-8'); ?>
           </td>
             <?php
             if(($i % 8) == 0)
               echo "</tr>";
         }
         if(($i % 8) != 0)
               echo "</tr>";
              ?>
   </table>
   </div>

   <div id="fragment-3">
   <div style="min-height: 20px"><div id="indicator" style="display: none"><?php echo image_tag("ajax-loading_2.gif", array("alt" => __("Čuva se"))) ?></div></div>


   <?php
   $glue = array("CasP", "Cas", "Cas1", "Cas2", "Cas3", "Cas4", "Cas5", "Cas6", "Cas7", "Cas8");
   $glue_naziv = array("Predcas", "Nulti", "1. čas", "2. čas", "3. čas", "4. čas", "5. čas", "6. čas", "7. čas", "8. čas");
   $i = 1;
   foreach($raspored_arr as $rasporeds)
   {?>
   <table class="raspored_holder" style='margin-top:10px;' border="1" cellpadding="0" cellspacing="0">
     <tr>
       <th style="width: 100px;" scope="col"><?php echo (($i++ > 1) ? 'Posle podne' : 'Pre podne') ?></th>
       <th scope="col">Ponedeljak</th>
       <th scope="col">Utorak</th>
       <th scope="col">Sreda</th>
       <th scope="col">Cetvrtak</th>
       <th scope="col">Petak</th>
       <th scope="col">Subota</th>
     </tr>

   <?php
       $k = 0;
       while($k < 10)
       {?>
       <tr>
       <th scope="row"><?php echo $glue_naziv[$k] ?></th>
       <?php
         $j = 1;
         foreach($rasporeds as $dan)
         {
           echo "<td>".select_tag($glue[$k].'_'.$dan['Id'], options_for_select($predmets, $dan[$glue[$k]]), array("class" => "raspored_cas", "onchange" => jq_remote_function(array('form' => 'id=this.id', 'update' => 'feedback', 'url' => 'razred/changeRaspored?razred_id='.$sf_request->getParameter('razred_id'), 'loading'  => '$("#indicator").show()', 'complete' => '$("#indicator").hide()'))))."</td>";
         }
         echo "</tr>";
         $k++;
       }

       echo "</table>";
   }
   ?>
   </div>

</div>